import java.util.List;
import java.util.Stack;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 25228
 * Date: 2024-08-03
 * Time: 15:25
 */
class MinStack {
    Stack<Integer> list1=new Stack<>();
    Stack<Integer> list2=new Stack<>();
    int min;
    public MinStack() {

    }

    public void push(int val) {
        list1.push(val);
        if(list2.isEmpty()){
            min=val;
            list2.push(min);
        }
        list2.push(Math.min(getMin(),val));
    }

    public void pop() {
        list1.pop();
        list2.pop();
    }

    public int top() {
        return list1.peek();
    }

    public int getMin() {
        return list2.peek();
    }
}
